package pl.edu.agh.student.janikhankus.tree;

/**
 * Class which represents abstract symbol.
 * 
 * @author Jaroslaw Janik
 */
public abstract class Symbol implements Comparable<Symbol> {

	protected String name;
	
	/**
	 * Constructor which sets symbol's name.
	 * 
	 * @param name Symbol name.
	 */
	public Symbol(String name) {
		this.name = name;
	}

	/**
	 * Returns symbol's name.
	 * 
	 * @return Symbol's name.
	 */
	public String getName() {
		return name;
	}

	/**
	 * Sets symbol's name.
	 * 
	 * @param name Symbol's name.
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * Returns object as instance of Terminal
	 */
	public Terminal asTerminal() {
		return null;
	}
	
	/**
	 * Returns object as instance of NonTerminal
	 */
	public NonTerminal asNonTerminal() {
		return null;
	}
	
	/**
	 * Returns object as instance of Epsylon
	 */
	public Epsylon asEpsylon() {
		return null;
	}
	
	@Override
	public int compareTo(Symbol s){
		if(this == s){
			return 0;
		}
		if(this.getName().equals(s.getName()) ){
			return 0;
		}
		return 1;
	}
	
	@Override
	public boolean equals(Object o){
		if((this != o) || !(o instanceof Symbol)){
			return false;
		}
		Symbol s = (Symbol)o;
		if(this == s){
			return true;
		}
		if(this.getName().equals(s.getName()) ){
			return true;
		}
		return false;
	}
	
	@Override
	public int hashCode()
	{
		return (new Integer(4)).hashCode();
	}
}
